package ai

import (
	"fmt"

	"yanxue_ai_go/pkg/common/ai/types"
	"yanxue_ai_go/pkg/common/config"
)

// ModelFactory 模型工厂
type ModelFactory struct {
	config *config.Config
}

// NewModelFactory 创建模型工厂
func NewModelFactory(cfg *config.Config) *ModelFactory {
	return &ModelFactory{
		config: cfg,
	}
}

// CreateModel 创建模型实例
func (f *ModelFactory) CreateModel(provider types.ModelProvider, modelName string, customConfig map[string]interface{}) (types.AIModel, error) {
	return nil, fmt.Errorf("model creation temporarily disabled to resolve import cycle")
}

// CreateModelsFromConfig 从配置创建所有模型
func (f *ModelFactory) CreateModelsFromConfig() ([]types.AIModel, error) {
	return nil, fmt.Errorf("model creation temporarily disabled to resolve import cycle")
}

// ParseModelID 解析模型ID
func ParseModelID(modelID string) (types.ModelProvider, string, error) {
	return "", "", fmt.Errorf("model parsing temporarily disabled to resolve import cycle")
}

// GetDefaultModel 获取默认模型配置
func GetDefaultModel(provider types.ModelProvider) string {
	switch provider {
	case types.ProviderOpenAI:
		return "gpt-3.5-turbo"
	case types.ProviderAnthropic:
		return "claude-3-sonnet-20240229"
	case types.ProviderOllama:
		return "llama2"
	case types.ProviderLocal:
		return "local-model"
	case types.ProviderCustom:
		return "custom-model"
	default:
		return "gpt-3.5-turbo"
	}
}

// GetSupportedProviders 获取支持的提供商列表
func GetSupportedProviders() []types.ModelProvider {
	return []types.ModelProvider{
		types.ProviderOpenAI,
		types.ProviderAnthropic,
		types.ProviderOllama,
		types.ProviderLocal,
		types.ProviderCustom,
	}
}

// GetProviderFeatures 获取提供商支持的功能
func GetProviderFeatures(provider types.ModelProvider) []string {
	switch provider {
	case types.ProviderOpenAI:
		return []string{"chat", "streaming", "tools", "vision", "embedding"}
	case types.ProviderAnthropic:
		return []string{"chat", "streaming", "reasoning"}
	case types.ProviderOllama:
		return []string{"chat", "streaming", "local"}
	case types.ProviderLocal:
		return []string{"chat", "local", "privacy"}
	case types.ProviderCustom:
		return []string{"chat", "custom"}
	default:
		return []string{}
	}
}
